package com.zjw.processor;

import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeSpec;

import java.util.HashMap;
import java.util.Map;

import javax.lang.model.element.Modifier;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.Elements;

/**
 * @author ：zhong.jw
 * @date ：Created in 2022/9/27 8:49
 */
public class CreateServiceProxy {

    private final String mClassName;
    private final String mPackageName;
    private final TypeElement mTypeElement;
    private final Class<?> clazz;

    public CreateServiceProxy(Elements elementUtils, TypeElement classElement, Class<?> iInterface) {
        this.mTypeElement = classElement;
        PackageElement packageElement = elementUtils.getPackageOf(mTypeElement);
        String packageName = packageElement.getQualifiedName().toString();
        String className = mTypeElement.getSimpleName().toString();
        this.mPackageName = packageName;
        this.mClassName = className;
        this.clazz = iInterface;
    }

    public String getClassName() {
        return mClassName;
    }

    public String getPackageName() {
        return mPackageName;
    }

    public String getCompleteName() {
        return mPackageName + mClassName;
    }

    public Class<?> getClazz() {
        return clazz;
    }

    public String getFieldName() {
        return "s" + mClassName;
    }

    public String newObject() {
        return "new " + getCompleteName();
    }
}